<?php
/**
 * Created By virus_cms
 * Author: Virus
 * Date: 2020/3/23
 * Time: 14:00
 */

namespace app\common\model\mysql;

use app\admin\library\traits\Backend;
use think\Model;

class Category extends Model
{
    protected $autoWriteTimestamp = true;

    use Backend;

    public function getStatusAttr($value)
    {
        return $value ? "开启" : "关闭";
    }

    public function getPidCategory($where, $order, $field = true)
    {
        return $this->where($where)
            ->field($field)
            ->order($order)
            ->find();
    }

    public function updateCategory($data)
    {
        if (empty($data) || !is_array($data)) {
            return false;
        }

        return $this->update($data);
    }
}